home *** CD-ROM | disk | FTP | other *** search
- /* -----------------------------------------------------------------------------
-
- <INSERT PROJECT DESCRIPTION HERE AND DELETE THIS LINE>
-
- */
-
- /* /// "includes" */
-
- /* include typical set of standard headers */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <stdarg.h>
-
- /* include typical set of Amiga headers */
-
- #include <exec/exec.h>
- #include <dos/dos.h>
- #include <dos/dostags.h>
- #include <dos/dosextens.h>
- #include <dos/datetime.h>
- #include <graphics/gfx.h>
- #include <graphics/gfxmacros.h>
- #include <graphics/layers.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
- #include <workbench/workbench.h>
- #include <workbench/startup.h>
- #include <workbench/icon.h>
- #include <datatypes/pictureclass.h>
- #include <libraries/asl.h>
- #include <libraries/commodities.h>
- #include <libraries/gadtools.h>
- #include <libraries/iffparse.h>
- #include <libraries/locale.h>
- #include <rexx/rxslib.h>
- #include <rexx/storage.h>
- #include <rexx/errors.h>
- #include <utility/hooks.h>
-
- /* include prototypes (#define INCLUDE_PRAGMAS to include pragmas to use registered arguments) */
-
- #ifdef INCLUDE_PRAGMAS
-
- #include <proto/asl.h>
- #include <proto/commodities.h>
- #include <proto/datatypes.h>
- #include <proto/diskfont.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/gadtools.h>
- #include <proto/graphics.h>
- #include <proto/icon.h>
- #include <proto/iffparse.h>
- #include <proto/intuition.h>
- #include <proto/layers.h>
- #include <proto/locale.h>
- #include <proto/rexxsyslib.h>
- #include <proto/utility.h>
- #include <proto/wb.h>
-
- #else
-
- #include <clib/asl_protos.h>
- #include <clib/commodities_protos.h>
- #include <clib/datatypes_protos.h>
- #include <clib/diskfont_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/icon_protos.h>
- #include <clib/iffparse_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/layers_protos.h>
- #include <clib/locale_protos.h>
- #include <clib/rexxsyslib_protos.h>
- #include <clib/utility_protos.h>
- #include <clib/wb_protos.h>
-
- #endif
-
- /* /// */
- /* /// "prototypes" */
-
- extern int main (int argc, char **argv);
- extern int wbmain (struct WBStartup *wbs);
- extern struct Config *Init (void);
- extern int Main (struct Config *config);
- extern void CleanUp(struct Config *config);
-
- /* /// */
- /* /// "definitions" */
-
- /* EDIT PROGRAM NAME AND VERSION AND DELETE THIS LINE */
-
- #define PROGRAMNAME "unnamed"
- #define VERSION "1.0"
-
- /* change #define to #undef to disable start via workbench */
-
- #define GENERATEWBMAIN
-
- /* define command syntax and number of options */
-
- #define RDARGS_TEMPLATE ""
- #define RDARGS_OPTIONS 0
-
- /* define amiga-style version tag */
-
- #if defined(__SASC)
- const UBYTE VersionTag[] = "$VER: " PROGRAMNAME " " VERSION " " __AMIGADATE__ "\n\0";
- #elif defined(_DCC)
- const UBYTE VersionTag[] = "$VER: " PROGRAMNAME " " VERSION " (" __COMMODORE_DATE__ ")\n\0";
- #else
- const UBYTE VersionTag[] = "$VER: " PROGRAMNAME " " VERSION " (" __DATE__ ")\n\0";
- #endif
-
- /* /// */
- /* /// "struct" */
-
- /* ---------------------------------- Config -----------------------------------
-
- Global data
-
- */
-
- struct Config
- {
- struct RDArgs *RDArgs;
-
- #if RDARGS_OPTIONS
-
- LONG Options[RDARGS_OPTIONS];
-
- #endif
-
- /* <INSERT YOUR GLOBAL DATA HERE AND DELETE THIS LINE> */
- };
-
- /* /// */
- /* /// "entry points" */
-
- /* ----------------------------------- main ------------------------------------
-
- Shell/wb entry point
-
- */
-
- int
- main(int argc, char **argv)
- {
- struct Config *config;
-
- if (argc == 0)
- {
- wbmain((struct WBStartup *)argv);
- }
- else if (config = Init())
- {
- #if RDARGS_OPTIONS
-
- /* parse startup options */
-
- int result;
-
- if (config->RDArgs = ReadArgs(RDARGS_TEMPLATE, config->Options, NULL))
- {
- result = Main(config);
- }
- else
- {
- PrintFault(IoErr(), PROGRAMNAME);
-
- result = 20;
- }
-
- #else
-
- int result = Main(config);
-
- #endif
-
- CleanUp(config);
-
- return(result);
- }
- else
- return(20);
- }
-
- /* ---------------------------------- wbmain -----------------------------------
-
- Workbench entry point
-
- */
-
- int
- wbmain(struct WBStartup *wbs)
- {
- #ifdef GENERATEWBMAIN
-
- struct Config *config;
-
- if (config = Init())
- {
- int result = Main(config);
-
- CleanUp(config);
-
- return(result);
- }
- else
- return(20);
-
- #else
-
- return(20);
-
- #endif
- }
-
- /* /// */
- /* /// "initialize" */
-
- /* ----------------------------------- Init ------------------------------------
-
- Initialize program. Allocate a config structure to store configuration data.
-
- */
-
- struct Config *
- Init()
- {
- struct Config *config;
-
- if (config = (struct Config *)malloc(sizeof(struct Config)))
- {
- memset(config, 0, sizeof(struct Config));
-
- /* <INSERT YOUR INITIALIZATION CODE HERE AND DELETE THIS LINE> */
- }
-
- return(config);
- }
-
- /* /// */
- /* /// "main" */
-
- /* ----------------------------------- Main ------------------------------------
-
- Main program. Result: 0 (ok), 5 (warning), 20 (fatal error)
-
- */
-
- int
- Main(struct Config *config)
- {
- /* <INSERT YOUR MAIN PROGRAM CODE HERE AND DELETE THIS LINE> */
-
- ;
-
- return(0);
- }
-
- /* /// */
- /* /// "cleanup" */
-
-
- /* ---------------------------------- CleanUp ----------------------------------
-
- Free allocated resources
-
- */
-
- void
- CleanUp(struct Config *config)
- {
- if (config)
- {
- /* <INSERT YOUR CLEAN-UP CODE HERE AND DELETE THIS LINE> */
-
- #if RDARGS_OPTIONS
-
- if (config->RDArgs)
-
- FreeArgs(config->RDArgs);
- #endif
-
- free(config);
- }
- }
-
- /* /// */
-